import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true,
  },
  {
    path: '/outcalldetail', // 外呼详情单页
    component: () => import('@/views/singlePage/outCallDetail/index'),
    hidden: true,
  },
  {
    path: '/outCallStatistics', // 外呼统计单页
    component: () => import('@/views/singlePage/outCallStatistics/index'),
    hidden: true,
  },
  {
    path: '/outCallStatisticsPc', // 外呼统计单页pc
    component: () => import('@/views/singlePage/outCallStatistics/indexPc'),
    hidden: true,
  },
  {
    path: '/realTimeData', // 实时数据监测平台（移动）
    component: () => import('@/views/singlePage/realTimeData/index'),
    hidden: true,
  },
  {
    path: '/realTimeData/assetDisposal', // 实时数据监测平台（移动）- 资产处置
    component: () => import('@/views/singlePage/realTimeData/assetDisposal'),
    hidden: true,
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true,
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: '首页', icon: 'dashboard', affix: true },
      },
    ],
  },
  {
    path: '/customer',
    component: Layout,
    meta: {
      title: '客户管理',
      icon: 'ziXun',
    },
    redirect: '/customer/customerPool',
    children: [
      {
        path: 'intendedCustomer',
        component: () => import('@/views/customer/intendedCustomer/index'),
        name: 'IntendedCustomer',
        meta: { title: '意向客户' },
      },
      {
        path: 'myCustomer',
        component: () => import('@/views/customer/myCustomer/index'),
        name: 'MyCustomer',
        meta: { title: '我的客户' },
      },
      {
        path: 'serviceConfig',
        component: () => import('@/views/customer/serviceConfig/index'),
        name: 'ServiceConfig',
        meta: { title: '业务配置' },
      },
      {
        path: 'applyCustomer',
        component: () => import('@/views/customer/applyCustomer/index'),
        name: 'ApplyCustomer',
        meta: { title: '申领客户' },
      },
      {
        path: 'customerPool',
        component: () => import('@/views/customer/customerPool/index'),
        name: 'CustomerPool',
        meta: { title: '客户池' },
      },
      {
        path: 'CRMCustomer',
        component: () => import('@/views/customer/CRMCustomer/index'),
        name: 'CRMCustomer',
        meta: { title: 'CRM客户' },
      },
      {
        path: 'disposalCustomer',
        component: () => import('@/views/customer/disposalCustomer/index'),
        name: 'DisposalCustomer',
        meta: { title: '处置信息客户' },
      },
      {
        path: 'plasticCustomer',
        component: () => import('@/views/customer/plasticCustomer/index'),
        name: 'PlasticCustomer',
        meta: { title: '回收塑料客户' },
      },
      {
        path: 'recurringCustomer',
        component: () => import('@/views/customer/recurringCustomer/index'),
        name: 'RecurringCustomer',
        meta: { title: '聚循环客户' },
      },
      {
        path: 'foreignStatistics',
        component: () => import('@/views/customer/foreignStatistics/index'),
        name: 'ForeignStatistics',
        meta: { title: '国外数据统计' },
      },
      {
        path: 'foreignCustomer',
        component: () => import('@/views/customer/foreignCustomer/index'),
        name: 'ForeignCustomer',
        meta: { title: '国外数据列表' },
      },
      {
        path: 'adCustomer',
        component: () => import('@/views/customer/adCustomer/index'),
        name: 'AdCustomer',
        meta: { title: '广告客户' },
      },
      {
        path: 'customerPoolDetail',
        component: () => import('@/views/customer/customerPool/detail'),
        name: 'CustomerPoolDetail',
        meta: { title: '客户池详情' },
      },
    ],
  },
  {
    path: '/lable',
    component: Layout,
    meta: {
      title: '标签管理',
      icon: 'ziXun',
    },
    redirect: '/lable/lableH',
    children: [
      {
        path: 'lableH',
        component: () => import('@/views/lable/lableH'),
        name: 'LableH',
        meta: { title: '标签管理' },
      },
    ],
  },
  {
    path: '/industryData',
    component: Layout,
    meta: {
      title: '行业数据',
      icon: 'ziXun',
    },
    redirect: '/industryData/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/industryData/dashboard/index'),
        name: 'Dashboard',
        meta: { title: '数据大屏' },
      },
      {
        path: 'memberDynamics',
        component: () => import('@/views/industryData/memberDynamics/index'),
        name: 'MemberDynamics',
        meta: { title: '明细-会员动态' },
      },
      {
        path: 'currentMember',
        component: () => import('@/views/industryData/currentMember/index'),
        name: 'CurrentMember',
        meta: { title: '明细-当前会员' },
      },
      {
        path: 'assetsDetail',
        component: () => import('@/views/industryData/assetsDetail/index'),
        name: 'AssetsDetail',
        meta: { title: '明细-资产处置' },
      },
      {
        path: 'auctionDetail',
        component: () => import('@/views/industryData/auctionDetail/index'),
        name: 'AuctionDetail',
        meta: { title: '明细-招标拍卖' },
      },
    ],
  },
  {
    path: '/auctionIndustryData',
    component: Layout,
    meta: {
      title: '聚拍行业数据',
      icon: 'ziXun',
    },
    redirect: '/auctionIndustryData/yunZhuJiCai',
    children: [
      {
        path: 'yunZhuJiCai',
        component: () => import('@/views/auctionIndustryData/yunZhuJiCai/index'),
        name: 'YunZhuJiCai',
        meta: { title: '云筑集采' },
      },
      {
        path: 'yunZhuJiCaiDetail',
        component: () => import('@/views/auctionIndustryData/yunZhuJiCai/detail'),
        name: 'YunZhuJiCaiDetail',
        meta: { title: '云筑集采详情' },
      },
    ],
  },
  {
    path: '/message',
    component: Layout,
    meta: {
      title: '短信管理',
      icon: 'ziXun',
    },
    redirect: '/message/msgManagement',
    children: [
      {
        path: 'msgManagement',
        component: () => import('@/views/message/msgManagement/index'),
        name: 'MsgManagement',
        meta: { title: '短信管理' },
      },
      {
        path: 'msgManagementDetail',
        component: () => import('@/views/message/msgManagement/detail'),
        name: 'MsgManagementDetail',
        meta: { title: '短信执行-任务详情' },
      },
      {
        path: 'smsFlow',
        component: () => import('@/views/message/smsFlow.vue'),
        name: 'SmsFlow',
        meta: { title: '短信流水' },
      },
      {
        path: 'smsStatistics',
        component: () => import('@/views/message/smsStatistics.vue'),
        name: 'SmsStatistics',
        meta: { title: '短信统计' },
      },
    ],
  },
  {
    path: '/outboundCall',
    component: Layout,
    meta: {
      title: 'AI外呼管理',
      icon: 'ziXun',
    },
    redirect: '/outboundCall/outboundCallManager',
    children: [
      {
        path: 'outboundCallManager',
        component: () => import('@/views/outboundCall/outboundCallManager/index'),
        name: 'OutboundCallManager',
        meta: { title: 'AI外呼管理' },
      },
      {
        path: 'outCallManagerDetail',
        component: () => import('@/views/outboundCall/outboundCallManager/detail'),
        name: 'OutCallManagerDetail',
        meta: { title: '外呼执行-任务详情' },
      },
      {
        path: 'outCallFlow',
        component: () => import('@/views/outboundCall/outCallFlow/index.vue'),
        name: 'OutCallFlow',
        meta: { title: '外呼流水' },
      },
      {
        path: 'outCallStatistics',
        component: () => import('@/views/outboundCall/outCallStatistics.vue'),
        name: 'OutCallStatistics',
        meta: { title: '外呼统计' },
      },
    ],
  },
  {
    path: '/project',
    component: Layout,
    meta: {
      title: '项目管理',
      icon: 'ziXun',
    },
    redirect: '/project/projectArr',
    children: [
      {
        path: 'projectArr',
        component: () => import('@/views/project/projectArr/index'),
        name: 'ProjectArr',
        meta: { title: '项目添加' },
      },
      {
        path: 'projectManage',
        component: () => import('@/views/project/projectManage/index'),
        name: 'ProjectManage',
        meta: { title: '项目执行' },
      },
    ],
  },
  {
    path: '/task',
    component: Layout,
    meta: {
      title: '任务管理',
      icon: 'ziXun',
    },
    redirect: '/task/taskArr',
    children: [
      {
        path: 'taskArr',
        component: () => import('@/views/task/taskArr/index'),
        name: 'TaskArr',
        meta: { title: '任务管理' },
      },
    ],
  },
  {
    path: '/company',
    component: Layout,
    meta: {
      title: '企业管理',
      icon: 'ziXun',
    },
    redirect: '/company/sqManage',
    children: [
      {
        path: 'sqManage',
        component: () => import('@/views/company/sqManage/index'),
        name: 'SqManage',
        meta: { title: '顺企网企业' },
      },
      {
        path: 'hyManage',
        component: () => import('@/views/company/hyManage/index'), // Parent router-view
        name: 'HyManage',
        meta: { title: '黄页88网企业' },
      },
    ],
  },
  {
    path: '/wxapplet',
    component: Layout,
    meta: {
      title: '小程序管理',
      icon: 'wxapplet',
    },
    redirect: '/wxapplet/routine',
    children: [
      {
        path: 'routine',
        component: () => import('@/views/wxapplet/routine/index'),
        name: 'routine',
        meta: { title: '小程序管理' },
      },
      {
        path: 'advertising',
        component: () => import('@/views/wxapplet/advertising/index'), // Parent router-view
        name: 'advertising',
        meta: { title: '广告管理' },
      },
      {
        path: 'announcement',
        component: () => import('@/views/wxapplet/announcement/index'), // Parent router-view
        name: 'announcement',
        meta: { title: '公告管理' },
      },
      {
        path: 'secondhand',
        component: () => import('@/views/wxapplet/secondhand/index'), // Parent router-view
        name: 'secondhand',
        meta: { title: '二手处理网' },
      },
    ],
  },
  {
    path: '/association',
    component: Layout,
    meta: {
      title: '社群管理',
      icon: 'association',
    },
    redirect: '/association/grouptype',
    children: [
      {
        path: 'grouptype',
        component: () => import('@/views/association/grouptype/index'),
        name: 'grouptype',
        meta: { title: '群聊类型' },
      },
      {
        path: 'grouplist',
        component: () => import('@/views/association/grouplist/index'),
        name: 'grouplist',
        meta: { title: '群聊列表' },
      },
      {
        path: 'groupcheck',
        component: () => import('@/views/association/groupcheck/index'),
        name: 'groupcheck',
        meta: { title: '进群审核' },
      },
      {
        path: 'groupStatistics',
        component: () => import('@/views/association/groupStatistics/index'),
        name: 'groupStatistics',
        meta: { title: '群聊统计' },
      },
    ],
  },

  {
    path: '/system',
    component: Layout,
    meta: {
      title: '系统设置',
      icon: 'nested',
    },
    redirect: '/system/account',
    children: [
      {
        path: 'account',
        component: () => import('@/views/system/account/index'), // Parent router-view
        name: 'Account',
        meta: { title: '账号管理' },
      },
      {
        path: 'role',
        component: () => import('@/views/system/role/index'),
        name: 'Role',
        meta: { title: '角色管理' },
      },
      {
        path: 'menu',
        component: () => import('@/views/system/menu/index'),
        name: 'Menu',
        meta: { title: '菜单管理' },
      },
      {
        path: 'department',
        component: () => import('@/views/system/department/index'),
        name: 'Department',
        meta: { title: '部门管理' },
      },
      {
        path: 'logInfo',
        component: () => import('@/views/system/logInfo/index'),
        name: 'LogInfo',
        meta: { title: '系统日志' },
      },
    ],
  },
  {
    path: '/assetsDisposal',
    component: Layout,
    meta: {
      title: '资产处置合作',
      icon: 'nested',
    },
    redirect: '/assetsDisposal/contractCustomer',
    children: [
      {
        path: 'contractCustomer',
        component: () => import('@/views/assetsDisposal/contractCustomer/index'), // Parent router-view
        name: 'ContractCustomer',
        meta: { title: '合约客户' },
      },
      {
        path: 'pushRecord',
        component: () => import('@/views/assetsDisposal/pushRecord/index'), // Parent router-view
        name: 'PushRecord',
        meta: { title: '推送记录' },
      },
      {
        path: 'closedOrder',
        component: () => import('@/views/assetsDisposal/closedOrder/index'), // Parent router-view
        name: 'ClosedOrder',
        meta: { title: '成交订单' },
      },
      {
        path: 'CRMOperation',
        component: () => import('@/views/assetsDisposal/CRMOperation/index'), // Parent router-view
        name: 'CRMOperation',
        meta: { title: 'CRM运营' },
      },
    ],
  },
  {
    path: '/quotationPay',
    component: Layout,
    meta: {
      title: '行情付费转化',
      icon: 'nested',
    },
    redirect: '/quotationPay/index',
    children: [
      {
        path: 'index',
        component: () => import('@/views/quotationPay/index/index'), // Parent router-view
        name: 'Index',
        meta: { title: '首页' },
      },
      {
        path: 'todoList',
        component: () => import('@/views/quotationPay/todoList/index'), // Parent router-view
        name: 'TodoList',
        meta: { title: '待办列表' },
      },
      {
        path: 'feedbackForm',
        component: () => import('@/views/quotationPay/feedbackForm/index'), // Parent router-view
        name: 'FeedbackForm',
        meta: { title: '反馈表单' },
      },
      {
        path: 'goodsManagement',
        component: () => import('@/views/quotationPay/goodsManagement/videoCourse/index'), // Parent router-view
        name: 'GoodsManagement',
        meta: { title: '商品管理' },
        children: [
          {
            path: 'videoCourse',
            component: () => import('@/views/quotationPay/goodsManagement/videoCourse/index'), // Parent router-view
            name: 'VideoCourse',
            meta: { title: '视频课' },
          },
          {
            path: 'quotationReport',
            component: () => import('@/views/quotationPay/goodsManagement/quotationReport/index'), // Parent router-view
            name: 'QuotationReport',
            meta: { title: '行情分析报告' },
          },
          {
            path: 'memberCard',
            component: () => import('@/views/quotationPay/goodsManagement/memberCard/index'), // Parent router-view
            name: 'MemberCard',
            meta: { title: '会员卡' },
          },
        ],
      },
      {
        path: 'orderManagement',
        component: () => import('@/views/quotationPay/orderManagement/index'), // Parent router-view
        name: 'OrderManagement',
        meta: { title: '订单管理' },
      },
      {
        path: 'customerManagement',
        component: () => import('@/views/quotationPay/customerManagement/customerList/index'), // Parent router-view
        name: 'CustomerManagement',
        meta: { title: '客户管理' },
        children: [
          {
            path: 'customerList',
            component: () => import('@/views/quotationPay/customerManagement/customerList/index'), // Parent router-view
            name: 'CustomerList',
            meta: { title: '客户列表' },
          },
          {
            path: 'customerGroup',
            component: () => import('@/views/quotationPay/customerManagement/customerGroup/index'), // Parent router-view
            name: 'CustomerGroup',
            meta: { title: '客户分群' },
          },
          {
            path: 'customerPush',
            component: () => import('@/views/quotationPay/customerManagement/customerPush/index'), // Parent router-view
            name: 'CustomerPush',
            meta: { title: '客户推送' },
          },
        ],
      },
      {
        path: 'FAQManagement',
        component: () => import('@/views/quotationPay/FAQManagement/index'), // Parent router-view
        name: 'FAQManagement',
        meta: { title: 'FAQ管理' },
      },
      {
        path: 'dataStatistics',
        component: () => import('@/views/quotationPay/dataStatistics/orderStatistics/index'), // Parent router-view
        name: 'DataStatistics',
        meta: { title: '数据统计' },
        children: [
          {
            path: 'orderStatistics',
            component: () => import('@/views/quotationPay/dataStatistics/orderStatistics/index'), // Parent router-view
            name: 'OrderStatistics',
            meta: { title: '订单统计' },
          },
          {
            path: 'transformStatistics',
            component: () => import('@/views/quotationPay/dataStatistics/transformStatistics/index'), // Parent router-view
            name: 'TransformStatistics',
            meta: { title: '转化统计' },
          },
          {
            path: 'goodsStatistics',
            component: () => import('@/views/quotationPay/dataStatistics/goodsStatistics/index'), // Parent router-view
            name: 'GoodsStatistics',
            meta: { title: '商品统计' },
          },
          {
            path: 'customerStatistics',
            component: () => import('@/views/quotationPay/dataStatistics/customerStatistics/index'), // Parent router-view
            name: 'CustomerStatistics',
            meta: { title: '客户统计' },
          },
        ],
      },
    ],
  },
  {
    path: '/adManage',
    component: Layout,
    meta: {
      title: '广告管理',
      icon: 'adManage',
    },
    redirect: '/adManage/createAdImg',
    children: [
      {
        path: 'adTemplate',
        component: () => import('@/views/adManage/adTemplate/index'), // Parent router-view
        name: 'AdTemplate',
        meta: { title: '广告模板' },
      },
      {
        path: 'createAdImg',
        component: () => import('@/views/adManage/createAdImg/index'), // Parent router-view
        name: 'CreateAdImg',
        meta: { title: '生成广告图' },
      },
    ],
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true },
]

export const asyncRoutes = []

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes,
  })

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
